package com.demo.jinjunhuang.viewsdemo.practice;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.View;

/**
 * @author jianjunhuang.me@foxmail.com
 *         create on 2017/8/25.
 */

public class StrokeCJView extends View {
    public StrokeCJView(Context context) {
        super(context);
    }

    public StrokeCJView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public StrokeCJView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public StrokeCJView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    Paint paint = new Paint();

    Path path = new Path();

    {
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeCap(Paint.Cap.ROUND);
        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStrokeWidth(50);
        path.lineTo(100, 100);
        path.lineTo(300, 100);
        path.lineTo(300, 500);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawPath(path, paint);
    }
}
